| Class | SimplyPresentable::ArrayPartialPresenter |
| In: |
vendor/plugins/simply_presentable/lib/simply_presentable/presenter/array_partial.rb
|
| Parent: | SimplyPresentable::PartialPresenter |
Renders the partial index in the partial_dir argument and binds the array to a variable with the same name as the partial_dir.
Options:
| :variable_name: | The name of the variable in the partial template that the array will be bound to |
| :partial: | An alternate (to index) partial to render |
# File vendor/plugins/simply_presentable/lib/simply_presentable/presenter/array_partial.rb, line 33
33: def render_as(partial_dir, options = {})
34: @renderer.render(@presenter_proxy.partial_options(options.reverse_deep_merge(:variable_name => partial_dir, :partial_dir => partial_dir)))
35: end
Renders each object in the array by calling:
present(element_in_array).render(options)
Options:
| :spacer_template: | The partial for a spacer template that should be rendered between each
element partial.
Example: [first_foo, second_foo].render_each(:spacer_template => 'foos/between') |
# File vendor/plugins/simply_presentable/lib/simply_presentable/presenter/array_partial.rb, line 14
14: def render_each(options = {})
15: local_options = options.dup
16: spacer = local_options[:spacer_template] ? @renderer.render(:partial => local_options.delete(:spacer_template)) : ''
17: counter = -1
18: partials = @presenter_proxy.map do |e|
19: counter += 1
20: presented_element = @renderer.present(e)
21: presented_element.render(local_options.reverse_deep_merge(:locals => { presented_element.partial_counter_name => counter }))
22: end
23: partials.join(spacer)
24: end